import { Module } from 'vuex'
import { getItem } from '@/utils/storage'
// initial state
const stateData = {
  routes: [],
  addRoutes: [],
  buttons: []
}

// 使用typeof推导ts类型
export type State = typeof stateData

const state = getItem<State>('permission') || stateData // 跟换此处名字为文件名

const store:Module<State, any> = {
  namespaced: true, // 为模块开启命名空间
  state,
  getters: {
    getRoutes: state => {
      return state.routes
    },
    getButtons: state => {
      return state.buttons
    }
  },
  mutations: {
  },
  actions: {
  }
}
export default store
